package uform.model.cell;
import thx.error.Error;

using Types;
import uform.model.core.Crawler;
import uform.model.core.IValueHandler;
import uform.model.value.ValueType;
import thx.util.Result;

class Cell<TType, TContainer> implements IValueHandler<TContainer>
{
	public var type : ValueType<TType>;
	function new(type : ValueType<TType>)
	{
		if (null == type)
			throw "null argument type";
		this.type = type;
	}
	
	public function parse(s : String, ?ref : { s : String }) : TContainer
	{
		return throw new Error("abstract method");
	}
	
	public function render(value : TContainer) : String
	{
		return throw new Error("abstract method");
	}
	
	public function isOptional() : Bool
	{
		return throw new Error("abstract method");
	}
	
	public function validate(value : Dynamic) : Result
	{
		return throw new Error("abstract method");
	}
	
	public function toString()
	{
		return this.typeName();
	}
	
	public function resolve(crawler : Crawler, param : String)
	{
		if (param != '')
			throw new Error("unexpected param '{0}'", param);
	}
}